<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="author" content="Guillaume Laborde - Guillaume Lameyre" />
<link rel="stylesheet" media="screen" type="text/css" title="style" href="css/style.css" />
<title>ContactBook</title>
</head>

<body>

	<c:set var="account" value="${sessionScope.account}"></c:set>
	<c:set var="groups" value="${requestScope.groups}"></c:set>
	<c:set var="nbGroups" value="${requestScope.nbGroups}" />

	<c:if test="${empty account}">
		<c:redirect url="Index" />
	</c:if>
	
	<div id="mainframe">
		<c:import url="include/privateBanner.html" />
		<h1>Gestion des groupes</h1>
		<div id="content">
		
			<form action="AddGroup" method="POST" class="right">
				<input type="image" src="images/group_add.png" alt="Ajouter un groupe" title="Cliquer ici pour ajouter un groupe" />
			</form>
		
			<c:if test="${nbGroups == '0'}" >
				<p class="warning">Vous n'avez créé aucun groupe pour le moment.</p>
				<p>Pour créer votre premier groupe, cliquez sur "Ajouter un groupe".</p>
			</c:if>

			<c:if test="${nbGroups != '0'}" >
				<fieldset>
					<legend>Liste des groupes</legend>
					<table class="border">
						<c:forEach var="group" items="${groups}">
							<jsp:useBean id="group" class="contactbook.model.Group" scope="page" />
							<tr>
								<form action="InfoGroup" method="POST">
									<td width="20px"><input type="image" src="images/group_go.png" alt="Voir" title="Voir le groupe" /></td>
			            			<td><input type="image" src="" alt="<jsp:getProperty name="group" property="name" />" title="Voir le groupe" /></td>
			            			<input type="hidden" name="groupId" value="<jsp:getProperty name="group" property="id" />" />
			            		</form>
			            		<td width="40px">
			            			<form action="UpdateGroup" method="POST" class="inline">
			           					<input type="image" src="images/group_edit.png" alt="Modifier" title="Modifier" />
			           					<input type="hidden" name="groupId" value="<jsp:getProperty name="group" property="id" />" />
			           				</form>
			           				<form action="DeleteGroup" method="POST" class="inline">
						            	<input type="image" src="images/group_delete.png" alt="Supprimer" title="Supprimer" />
						            	<input type="hidden" name="groupId" value="<jsp:getProperty name="group" property="id" />" />
						            </form>
								</td>
							</tr>
		            	</c:forEach>
	            	</table>
				</fieldset>
			</c:if>
	
		</div>
		<c:import url="include/bottom.html" />
	</div>
	
</body>
</html>